package com.jeeplus.cms.config.freemarker.function;

import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author WuXilin
 */
@Component("ctxStatic")
public class GetStaticPath implements TemplateMethodModelEx {

    @Autowired
    protected HttpServletRequest request;

    @Override
    public Object exec(List list) throws TemplateModelException {
        if (request == null) {
            return "";
        }
        return request.getContextPath() + "/static";
    }
}
